<?php

declare(strict_types=1);
/**
 * This file is part of MoChat.
 * @link     https://mo.chat
 * @document https://mochat.wiki
 * @contact  group@mo.chat
 * @license  https://github.com/mochat-cloud/mochat/blob/master/LICENSE
 */

namespace MoChat\App\Client\Logic\Detail;

use Hyperf\DbConnection\Db;

/**
 * 资质效期逻辑.
 *
 */
class LicenseLogic
{

    /**
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function handle(array $params): array
    {
        $res = Db::connection('b2b')->table('licence')->where('id', $params['clientId'])->first();
        if ($res) {
            $res = json_decode(json_encode($res), true);
            $res = my_array_change_key($res);
        } else {
            $res = [];
        }
        return $res;
    }
}
